package cn.stylefeng.guns.modular.system.utils;

import cn.stylefeng.guns.modular.system.enums.CodeEnum;

/**
 * @Author: lzy
 * @Description:
 * @Date: CREATE IN 2019/5/17 10:50
 */
public class EnumUtil {

    public static <T extends CodeEnum> T getByCode(String code , Class<T> clazz){
        for (T t : clazz.getEnumConstants()) {//遍历所有枚举
            if(code.equals(t.getCode())){//匹配枚举code
                return t;//返回该枚举
            }
        }
        return null;
    }

}
